<template>
    <div>
        <span class="text">{{dateYear}} {{dateWeek}} {{dateDay}}</span>
    </div>
</template>

<script>
    import {formatTime} from "../../utils";

    export default {
        name: "timer",
        data(){
            return {
                loading: true,
                dateDay: null,
                dateYear: null,
                dateWeek: null,
                weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
            };
        },
        mounted () {
            this.timeFn();
            this.cancelLoading();
        },
        methods: {
            timeFn () {
                setInterval(() => {
                    this.dateDay = formatTime(new Date(), 'HH: mm: ss');
                    this.dateYear = formatTime(new Date(), 'yyyy-MM-dd');
                    this.dateWeek = this.weekday[new Date().getDay()];
                }, 1000)
            },
            cancelLoading () {
                setTimeout(() => {
                    this.loading = false;
                }, 500);
            }
        }
    }
</script>

<style scoped>

</style>
